package com.snake.springboot.custom.service.assemble.base;


import com.snake.springboot.custom.api.model.base.CustSubAccountModel;
import com.snake.springboot.custom.api.request.base.CustSubAccQuery;
import com.snake.springboot.custom.dao.mybatis.entity.base.CustSubAccountDO;
import org.snake.common.code.SerialNumberGeneratorFactory;
import org.snake.common.security.MD5Util;
import org.snake.common.utils.PropertyUtils;

/**
 * <p>商户子账号组装器
 * 类{@code CustSubAccAssembler} </br>
 * 创建时间2025/2/8 15:58
 *
 * @author yangxt
 * @see
 */
public class CustSubAccAssembler {

    public static CustSubAccountDO subAccDOAss(CustSubAccountModel model,boolean isAdd) {
        if (isAdd){
            model.setSubAccountId(SerialNumberGeneratorFactory.buildId4Bean());
            model.setPassword(MD5Util.encrypt(model.getPassword()));
        }
        CustSubAccountDO accountDO = new CustSubAccountDO();
        PropertyUtils.copyProperties(accountDO,model);
        return accountDO;
    }

    public static CustSubAccountDO subAccQueryAss(CustSubAccQuery query) {
        CustSubAccountDO accountDO = new CustSubAccountDO();
        PropertyUtils.copyProperties(accountDO,query);
        return accountDO;
    }
}
